package com.dynamixsoftware.printershare;

import android.content.DialogInterface;
import android.content.DialogInterface.OnClickListener;
import android.content.res.Resources;
import android.os.Bundle;
import android.view.View;
import android.view.View.OnClickListener;
import android.widget.Button;
import android.widget.EditText;
import android.widget.Toast;
import com.dynamixsoftware.printershare.data.SoapEnvelope;
import com.dynamixsoftware.printershare.data.SoapService;
import com.dynamixsoftware.printershare.data.User;
import com.dynamixsoftware.printershare.data.XmlUtil;
import org.w3c.dom.Element;

public class ActivityProfileEdit
  extends ActivityCore
{
  protected void init()
  {
    super.init();
    if (user == null) {
      return;
    }
    ((EditText)findViewById(2131230744)).setText(user.name);
    ((EditText)findViewById(2131230745)).setText(user.nick);
    ((EditText)findViewById(2131230746)).setText(user.email);
    ((EditText)findViewById(2131230747)).setText(user.phone);
    ((EditText)findViewById(2131230748)).setText(user.address);
    ((EditText)findViewById(2131230814)).setText(user.city);
    ((EditText)findViewById(2131230815)).setText(user.state);
    ((EditText)findViewById(2131230816)).setText(user.zip);
    ((EditText)findViewById(2131230750)).setText(user.country);
  }
  
  public void onCreate(Bundle paramBundle)
  {
    super.onCreate(paramBundle);
    setContentView(2130903070);
    setTitle(2131099677);
    ((Button)findViewById(2131230812)).setOnClickListener(new View.OnClickListener()
    {
      public void onClick(View paramAnonymousView)
      {
        new ActivityProfileEdit.EditProfileThread(ActivityProfileEdit.this).start();
      }
    });
    ((Button)findViewById(2131230813)).setOnClickListener(new View.OnClickListener()
    {
      public void onClick(View paramAnonymousView)
      {
        ActivityProfileEdit.this.setResult(0);
        ActivityProfileEdit.this.finish();
      }
    });
  }
  
  class EditProfileThread
    extends Thread
  {
    EditProfileThread() {}
    
    public void run()
    {
      ActivityProfileEdit.this.runOnUiThread(new Runnable()
      {
        public void run()
        {
          ActivityProfileEdit.this.showProgress(ActivityProfileEdit.this.getResources().getString(2131099746));
        }
      });
      ActivityProfileEdit.this.last_error = null;
      try
      {
        SoapEnvelope localSoapEnvelope = new SoapEnvelope("UpdateProfile", "Param", "data");
        Element localElement1 = localSoapEnvelope.getDataRoot();
        XmlUtil.appendElement(localElement1, "token", ActivityCore.token);
        Element localElement2 = XmlUtil.appendElement(localElement1, "user");
        XmlUtil.appendElement(localElement2, "name", ((EditText)ActivityProfileEdit.this.findViewById(2131230744)).getEditableText().toString());
        XmlUtil.appendElement(localElement2, "nick", ((EditText)ActivityProfileEdit.this.findViewById(2131230745)).getEditableText().toString());
        XmlUtil.appendElement(localElement2, "mail", ((EditText)ActivityProfileEdit.this.findViewById(2131230746)).getEditableText().toString());
        XmlUtil.appendElement(localElement2, "phone", ((EditText)ActivityProfileEdit.this.findViewById(2131230747)).getEditableText().toString());
        XmlUtil.appendElement(localElement2, "address", ((EditText)ActivityProfileEdit.this.findViewById(2131230748)).getEditableText().toString());
        XmlUtil.appendElement(localElement2, "city", ((EditText)ActivityProfileEdit.this.findViewById(2131230814)).getEditableText().toString());
        XmlUtil.appendElement(localElement2, "state", ((EditText)ActivityProfileEdit.this.findViewById(2131230815)).getEditableText().toString());
        XmlUtil.appendElement(localElement2, "zip", ((EditText)ActivityProfileEdit.this.findViewById(2131230816)).getEditableText().toString());
        XmlUtil.appendElement(localElement2, "country", ((EditText)ActivityProfileEdit.this.findViewById(2131230750)).getEditableText().toString());
        Element localElement3 = ActivityProfileEdit.this.psService.doAction(localSoapEnvelope).getDataRoot();
        if ("true".equals(localElement3.getAttribute("success")))
        {
          User localUser = new User();
          localUser.readFromXml(localElement2);
          ActivityCore.user = localUser;
        }
        while (ActivityProfileEdit.this.last_error == null)
        {
          ActivityProfileEdit.this.runOnUiThread(new Runnable()
          {
            public void run()
            {
              ActivityProfileEdit.this.hideProgress();
              ActivityProfileEdit.this.setResult(-1);
              ActivityProfileEdit.this.finish();
              Toast.makeText(ActivityProfileEdit.this.getApplication(), 2131099688, 1).show();
            }
          });
          return;
          ActivityProfileEdit.this.last_error = ("Error: " + XmlUtil.getFirstNodeValue(localElement3, "message"));
        }
      }
      catch (Exception localException)
      {
        for (;;)
        {
          localException.printStackTrace();
          ActivityProfileEdit.this.last_error = ("Internal Error: " + localException.getMessage());
          App.reportThrowable(localException);
        }
        ActivityProfileEdit.this.runOnUiThread(new Runnable()
        {
          public void run()
          {
            ActivityProfileEdit.this.hideProgress();
            ActivityProfileEdit.this.displayLastError(new DialogInterface.OnClickListener()
            {
              public void onClick(DialogInterface paramAnonymous2DialogInterface, int paramAnonymous2Int) {}
            });
          }
        });
      }
    }
  }
}


/* Location:           C:\Users\Admin\Desktop\Decompiler\JAD\jd-gui-0.3.6.windows\classes_dex2jar.jar
 * Qualified Name:     com.dynamixsoftware.printershare.ActivityProfileEdit
 * JD-Core Version:    0.7.0.1
 */